package tongcheng.com.tongcheng.ui.yemian.shenfen.fragment;

import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.load.resource.bitmap.CircleCrop;

import butterknife.Bind;
import butterknife.ButterKnife;
import tongcheng.com.tongcheng.ConStans;
import tongcheng.com.tongcheng.R;
import tongcheng.com.tongcheng.base.BaseFragment;
import tongcheng.com.tongcheng.base.main.activity.GeRenXinxiActivity;
import tongcheng.com.tongcheng.base.main.activity.MessageActivity;
import tongcheng.com.tongcheng.base.main.activity.SettingActivity;
import tongcheng.com.tongcheng.base.main.activity.WebViewActivity;
import tongcheng.com.tongcheng.base.xinyong.XinYongFenActivity;
import tongcheng.com.tongcheng.ui.yemian.shenfen.activity.install.InstallOrderDetial;
import tongcheng.com.tongcheng.utils.GlideApp;
import tongcheng.com.tongcheng.utils.Setting;

/**
 * Created by P on 2017/7/31.
 * 安装人员-个人中心
 */

public class InstallPersonCenterFragment extends BaseFragment {


    @Bind(R.id.back)
    ImageView mBack;
    @Bind(R.id.title)
    TextView mTitle;

    @Bind(R.id.title_bar)
    RelativeLayout mTitleBar;
    @Bind(R.id.installpeople_icon)
    ImageView mInstallpeopleIcon;
    @Bind(R.id.installpeople_ll1)
    LinearLayout mInstallpeopleLl1;
    @Bind(R.id.installpeople_dailishang)
    LinearLayout mInstallpeopleDailishang;
    @Bind(R.id.installpeople_message)
    LinearLayout mInstallpeopleMessage;
    @Bind(R.id.installpeople_setting)
    LinearLayout mInstallpeopleSetting;
    @Bind(R.id.title_icons)
    ImageView mTitleIcons;
    @Bind(R.id.installpeople_name)
    TextView mInstallPeopleName;
    @Bind(R.id.installpeople_jifen)
    TextView mInstallPeopleJifen;
    @Bind(R.id.ll_yongHuZhiNan)
    LinearLayout ll_yongHuZhiNan;
    @Bind(R.id.ll_yaoQingHaoYou)
    LinearLayout ll_yaoQingHaoYou;

    @Override
    public void FragmentStart() {

    }

    @Override
    public Integer setFragmentView() {
        return R.layout.fragment_installpersoncenter;
    }

    @Override
    public void onResume() {
        super.onResume();
        //初始化头像
        GlideApp.with(this).load(ConStans.BaseUrl_Test_url + Setting.getTouXiang()).into(mTitleIcons);
        GlideApp.with(this).load(ConStans.BaseUrl_Test_url + Setting.getTouXiang()).transform(new CircleCrop()).into(mInstallpeopleIcon);
        mInstallPeopleName.setText(Setting.getUserName() + "");
        mInstallPeopleJifen.setText("信用积分:"+Setting.getXinYongFen()+">");
    }

    @Override
    public void FragmentCreate(View inflate) {

        ButterKnife.bind(this, inflate);
        settitlebar(mTitleBar);
/*
        GlideApp.with(this).load(ConStans.BaseUrl_Test_url + Setting.getTouXiang())

                .transform(new BlurTransformation(mContext,15,1))*/

       /* RequestOptions options = new RequestOptions();
        RequestOptions.bitmapTransform(new BlurTransformation(mContext, 100, 100));
        Glide.with(this).load(ConStans.BaseUrl_Test_url + Setting.getTouXiang()).apply(options)
               .into(mTitleIcons);*/

       /* Glide.with(this).load(ConStans.BaseUrl_Test_url + Setting.getTouXiang())
              .apply()*/
        //初始化头像
        GlideApp.with(this).load(ConStans.BaseUrl_Test_url + Setting.getTouXiang()).into(mTitleIcons);
        GlideApp.with(this).load(ConStans.BaseUrl_Test_url + Setting.getTouXiang()).transform(new CircleCrop()).into(mInstallpeopleIcon);
        //初始化名字
        mInstallPeopleName.setText(Setting.getUserName() + "");
        //初始化积分
        mInstallPeopleJifen.setText("信用积分:"+Setting.getXinYongFen()+">");
        mInstallPeopleJifen.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startactivity(mContext, XinYongFenActivity.class);
            }
        });
        mTitleBar.setBackgroundColor(0x00ffffff);
        mTitle.setText("个人中心");
        mTitle.setTextColor(Color.WHITE);
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getActivity().finish();
            }
        });

        mInstallpeopleDailishang.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent(mContext, InstallOrderDetial.class);
                intent.putExtra("id", Setting.getId());
                intent.putExtra("temp", "1");
                startActivity(intent);
               // startactivity(mContext, InstallOrderDetial.class);

            }
        });


        mInstallpeopleMessage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startactivity(mContext, MessageActivity.class);
            }
        });

        ll_yongHuZhiNan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent xnIntent = new Intent(mContext,WebViewActivity.class);
                xnIntent.putExtra("title","用户指南");
                xnIntent.putExtra("keyword",13);
                startActivity(xnIntent);
            }
        });

        mInstallpeopleSetting.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent xnIntent = new Intent(mContext,SettingActivity.class);
                xnIntent.putExtra("yongHuXieYi",6);
                mContext.startActivity(xnIntent);

//                startactivity(mContext, SettingActivity.class);
            }
        });

        mInstallpeopleIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startactivity(mContext, GeRenXinxiActivity.class);
            }
        });

        ll_yaoQingHaoYou.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showShare();
            }
        });

    }


}
